#pragma once

#include <QObject>
#include <QWidget>

class QStringView;
QT_FORWARD_DECLARE_CLASS(QLabel)
QT_FORWARD_DECLARE_CLASS(QPushButton)
QT_FORWARD_DECLARE_CLASS(QPoint)

class CDefTitle : public QWidget
{
	Q_OBJECT
private slots:
	void OnClickedBtn();

public:
	explicit CDefTitle(QWidget*parent);
	~CDefTitle()=default;

	void SetTitleText(QStringView title)noexcept;
	void SetTitleBarIcon(QStringView icon)noexcept;
protected:
	void InitSlot();
protected:
	virtual void mouseDoubleClickEvent(QMouseEvent* event)override;
	virtual void mousePressEvent(QMouseEvent* event)override;
	virtual void mouseReleaseEvent(QMouseEvent* event)override;
	virtual void mouseMoveEvent(QMouseEvent* event)override;
	virtual bool eventFilter(QObject* watched, QEvent* event)override;
private:
	void UpdateMaximizeRecover();
private:
	QLabel* m_iconLabel;
	QLabel* m_titleLabel;
	QPushButton* m_minimizeBtn;
	QPushButton* m_maximizeBtn;
	QPushButton* m_closeBtn;
	QPoint m_startPt;
	QPoint m_endPt;
	bool m_leftBtnPressed;	
};
